package main

import (
	"encoding/json"
	"fmt"
)

type Student struct {
	Name    string
	Age     int
	Guake   bool
	Classes []string
	Price   float32
}

func main() {

	st := &Student{
		"Xiao Ming",
		16,
		true,
		[]string{"Math", "English", "Chinese"},
		9.99,
	}

	b, err := json.Marshal(st)
	if err != nil {
		fmt.Println(" json error")
		return
	}

	fmt.Println("json:", string(b))

	stb := &Student{}

	err = json.Unmarshal([]byte(b), &stb)
	if err != nil {
		fmt.Println(" json error")
		return
	}

	fmt.Println("struct:", stb)
}
